package com.wang.springframework.beans;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangjianhua
 * @Description
 * @date 2021/8/24/024 13:45
 **/
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue pv){
        this.propertyValueList.add(pv);
    }

    public PropertyValue[] getPropertyValues(){
        //参数的意思是返回所有包括该参数类型的值 也就是泛型转换 不传参会报错
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName){
        for (PropertyValue propertyValue : this.propertyValueList) {
            if(propertyValue.getName().equals(propertyName)){
                return propertyValue;
            }
        }
        return null;
    }
}
